<?php
/**
 * 函数get_extension,实现获取文件后缀
 * @final
 * @param string $file_name 文件名 
 * @param boolean $lower 是否转换成小写
 * @return string $file_ext 文件后缀
 * @author Njs^Sydney hxtgirq710@qq.com
 * @version 1.0.0
 */
function get_extension($file_name,$lower=true){
	$file_ext = pathinfo($file_name,PATHINFO_EXTENSION);
	$lower && $file_ext = strtolower($file_ext);
	return $file_ext;
}

/**
 * @brother get_extension()
 */
function get_ext($file_name,$lower=true){
	return get_extension($file_name,$lower);
}

/**
 * 函数mkdirs创建目录可多级
 * @final
 * @param string $dir 要创建的目录
 * @return boolean $rst 创建结果
 * @author Njs^Sydney hxtgirq710@qq.com
 * @version 1.0.0
 */
function mkdirs($dir){
	if(!is_dir($dir)){
		if(!mkdirs(dirname($dir)))
			return false;
		if(!mkdir($dir,0777))
			return false;
	}
	return true;
}

/**
 * 函数cut_str 截取字符串
 * @final
 * @param string $str 待截取的字符串
 * @param int $start  截取的开始位置
 * @param int $length 截取的长度
 * @param string $charset 字符串编码
 * @param string $suffix 截取后附加字符
 * @author Njs^Sydney hxtgirq710@qq.com
 * @version 1.0.0
 */
function cut_str($str,$start=0,$length,$charset="utf-8",$suffix="..."){
	$str = strip_tags(htmlspecialchars_decode($str));
	$str = str_replace(array("\r\n","\n\n","\r\r","\n","\r"),'',$str);
	$total_len = strlen($str);
	$data = '';
	if(function_exists("mb_substr")){
		$data = mb_substr($str,$start,$length,$charset);
	}elseif(function_exists("iconv_substr")){
		$data = iconv_substr($str,$start,$length,$charset);
	}else{
		$re['utf-8']  = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";
        $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/";
        $re['gbk']    = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/";
        $re['big5']   = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/";
        preg_match_all($re[$charset],$str,$match);
        $data = join("",array_slice($match[0],$start,$length));
	}
	if(strlen($str)>strlen($data)){
		$data .= $suffix;
	}
	return $data;
}

function face($content){
	$search = array(
		
	);
	$replace = array();
}

?>